package com.springapp.service.impl;

import com.github.pagehelper.PageHelper;
import com.springapp.dao.JobDao;
import com.springapp.domain.Job;
import com.springapp.service.JobService;
import com.springapp.util.BeanUtil;
import com.springapp.util.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * JobService的实现类
 * <p/>
 * Created by 雪峰 on 2016/5/6.
 */
@Service
public class JobServiceImpl implements JobService {
    @Resource
    private JobDao jobDao;

    @Override
    public PageResult<Job> queryByPage(String job, Integer pageNo, Integer pageSize) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;
        PageHelper.startPage(pageNo, pageSize); //startPage是用于告诉拦截器要开始分页了，传入两个分页参数
        return BeanUtil.toPageResult(jobDao.selectAllJob(job));
    }
}
